package com.pri.chat.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pri.chat.R;
import com.netease.nim.uikit.net.entity.MessageBean;
import com.pri.chat.utils.TimeUtils;
import com.pri.chat.view.ImageViewPlus;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/9
 */
public class DialogCommentAdapter extends BaseQuickAdapter<MessageBean, BaseViewHolder> {
    public DialogCommentAdapter(int layoutResId, @Nullable List<MessageBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageBean item) {
        helper.addOnClickListener(R.id.iv_logo);
        helper.setText(R.id.tv_comment_time, TimeUtils.computeFromNowStr(item.getAddDate()));
        helper.setText(R.id.tv_comment_desc,item.getContent());
        helper.setText(R.id.tv_dt_age,item.getAge()+"");
        helper.setText(R.id.tv_comment_name,item.getMemberName());
        Glide.with(mContext).load(item.getHeadPic()).into((ImageViewPlus)helper.getView(R.id.iv_logo));

        View sexLinear = helper.getView(R.id.sex_bg);
        ImageView sexLogo = helper.getView(R.id.sex_logo);
        if(item.getSex().equals("男")){
            sexLogo.setImageResource(R.mipmap.man);
            sexLinear.setBackgroundResource(R.drawable.btn_sex_man);
        }else{
            sexLogo.setImageResource(R.mipmap.woman);
            sexLinear.setBackgroundResource(R.drawable.btn_sex_woman);
        }
    }
}